package struts.ext.util.converter;

public class BooleanFormatter implements AttrFormatter{

	private String ifTrue;
	private String ifFalse;
	
	public BooleanFormatter(String ifTrue, String ifFalse) {
		this.ifFalse = ifFalse;
		this.ifTrue = ifTrue;
	}
	
	@Override
	public String format(Object value) throws Exception {
		if(value instanceof Boolean){
			return (Boolean)value ? ifTrue : ifFalse;
		}
		throw new Exception("格式化失败。" + value + "不是Boolean类型数据");
	}
	
	public String getIfTrue() {
		return ifTrue;
	}
	public void setIfTrue(String ifTrue) {
		this.ifTrue = ifTrue;
	}
	public String getIfFalse() {
		return ifFalse;
	}
	public void setIfFalse(String ifFalse) {
		this.ifFalse = ifFalse;
	}
	
}
